<template>
    <div>
        <table>
            <tr>
                <td>套餐</td>
                <td>价格</td>
            </tr>
            <tr v-for="i in list_" :key="i.id">
                <td @click="btn(i.id)">{{i.name}}</td>
                <td>{{i.price}}</td>
            </tr>
        </table>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data () {
        return {
            list_:[],
            id:localStorage.getItem('id'),
            name:localStorage.getItem('name'),
        }
    },
    created () {
        axios.get('http://127.0.0.1:8000/user/show/').then((res)=>{
            this.list_ = res.data
        })
    },
    methods: {
        btn(id){
            axios.post('http://127.0.0.1:8000/user/start/',{'id':this.id,'uid':this.uid}).then((res)=>{
                alert(res.data.msg)
                if(res.data.code==200){
                    this.$router.push({'name':'show',query:{id:id}})
                }
                
            })
        }
    }
}
</script>

<style>

</style>